




import com.mysql.jdbc.jdbc2.optional.MysqlDataSource;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.Scanner;

public class TestMain {

    public static void main(String[] args) throws SQLException {
        MysqlDataSource dataSource = new MysqlDataSource();
        dataSource.setUrl("jdbc:mysql://127.0.0.1:3306/dream?characterEncoding=utf-8&&useSSL=false");
        dataSource.setUser("root");
        dataSource.setPassword("666666");
        Connection connection = dataSource.getConnection();
        Scanner sc = new Scanner(System.in);
        int id = sc.nextInt();
        String name = sc.nextLine();
        String s = "insert into student values(?,?)";
        PreparedStatement preparedStatement = connection.prepareStatement(s);
        preparedStatement.setInt(1,id);
        preparedStatement.setString(2,name);
        System.out.println(preparedStatement);
        int ret = preparedStatement.executeUpdate();
        System.out.println(ret);
        preparedStatement.close();
        connection.close();

    }
}
